Mac OS Sound

| Previous | Chapter Contents | Chapter Top | Next |

The Process of Converting a Sound

The process of Converting a sound involves the following steps:

  1. You call SoundConverterBeginConversion to initiate the conversion and reset the SoundConverter to default settings.
  2. SoundConverterConvertBuffer is called one or more times to convert sequential buffers of the input data to the output format.
  3. Finally, when all input data has been converted, SoundConverterEndConversion flushes out any data left in the converter.
pascal OSErr SoundConverterOpen(const SoundComponentData *inputFormat,
            const SoundComponentData *outputFormat, SoundConverter *sc)

SoundConverterOpen sets up the conversion session and returns a SoundConverter identifier to be passed to all further routines. The inputFormat parameter specifies the format of the sound data to be converted using a SoundComponentData structure. The following fields must be set up to describe the sound correctly:

Field Descriptions of SoundComponentData

flags
Set to 0

format
The sound format (i.e., 'raw', 'twos', 'MAC3', etc.)

numChannels
The number of channels (i.e., 1 = mono, 2 = stereo)

sampleSize
The sample size (i.e., 8 = 8-bit, 16 = 16-bit)

sampleRate
The sampling rate (in samples/second)

sampleCount
Set to 0

buffer
Set to 0

reserved
Set to 0

The outputFormat parameter specifies the output format, and must be passed fields similar to inputFormat. Output fields that are different from input fields will cause a conversion. For example, if the input sound format is 'raw' and the output format is 'MAC3' , the data resulting from the conversion will be compressed with MACE 3:1. This allows any combination of compression, decompression, channel conversion, sample size conversion and sampling rate conversion. A SoundConverter identifier is returned to manage the session, which must be passed to all further routines.

SoundConverterClose terminates the session and frees up all memory and services associated with this session.

pascal OSErr SoundConverterClose(SoundConverter sc)

© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |